/*
 * SmartCardFile.java
 *
 * Created on 14. November 2006, 13:55
 *
 * SmartCardFiles are the real EFs und DFs on the SmartCard. This class
 * definies methods to access to the smartcard over the CardService
 *
 *  This file is part of JSmex.
 *
 *  JSmex is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  JSmex is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

package jsmex.function;

import jsmex.cardservice.*;
import jsmex.function.FileProperties;

/**
 *
 * @author Tobias Senger
 */
public class SmartCardFile {
    
    private String name;
    private byte[] fid;
    private boolean isDF;
    public FileProperties fp;
    
    private static JSmexCardService jsmexcs;
    
    /** Creates a new instance of SmartCardFile */
    public SmartCardFile(String name, FileProperties fp) {
        this.name = name;
        this.fid = fp.getFID();
        this.fp = fp;
        this.isDF = fp.isDF();
        
    }
    
    public void setCardService(JSmexCardService jsmexcs) {
        this.jsmexcs = jsmexcs;
    }
    
    public SmartCardFile[] listFiles() { //liefert alle EFs und DFs unterhalb des aktuellen DF zurück. Die Aufgabe lass ich den CardSercvices zukommen
        //Verbinden zum CardSerice und dort die EFs und DFs lesen
        return jsmexcs.getFileList(this);
    }
    
    public boolean isDirectory() {
        //TODO prüfen ob es ein directory ist oder nicht.
        return isDF;
    }
    
    public String toString() {
        return name;
    }
    
    public byte[] getFid() {
        return fid;
    }
    
    public String getTypeOfFile() {
        if (isDF) return "DF";
        else return "EF";
    }
    
    
}
